package cn.tedu.lbs.basic.web.controller;

import cn.tedu.lbs.basic.web.service.UserGroupService;
import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.pojo.basic.param.UserGroupParam;
import com.tarena.lbs.pojo.basic.query.UserGroupQuery;
import com.tarena.lbs.pojo.basic.vo.UserGroupVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserGroupController {
    @Autowired
    private UserGroupService userGroupService;

    //查询用户人群 分页列表
    @PostMapping("/admin/basic/userGroup/list")
    public Result<PageResult<UserGroupVO>> pageList(@RequestBody UserGroupQuery query)
        throws BusinessException{
        return new Result<>(userGroupService.pageList(query));
    }
    //提交管理员 填写的用户人群表单
    @PostMapping("/admin/basic/userGroup/save")
    public Result<Void> addGroup(@RequestBody UserGroupParam param)
        throws BusinessException{
        userGroupService.addGroup(param);
        return Result.success();
    }
}
